﻿using EncryptDecrypt;
using Microsoft.WindowsAzure;

namespace KeyCreator
{
    class Program
    {
        static void Main(string[] args)
        {
            //Before running this you need to determine a certificate thumbprint
            //You can access this the certificate manager snapin (certmgr.msc)
            //You can use create a new, self-signed certificate for this purpose if you wish, using the following command line
            //makecert -sr LocalMachine -ss My -n "CN=AzureTableEncryption v1" -pe -sky exchange -len 2048
            //
            //Note, you may need to set permissions for the private key of the certificate. Determine what user runs your w3wp process (probably Network Service)
            //In the Certificate Manager Snapin (certmgr.msc) find your cert, right click -> Manage Private Keys
            //Add the correct user and grant "read" permissions.


            string acctConnectString = "UseDevelopmentStorage=true";
            string certThumbprint = "‎‎90 50 8b 93 84 b1 c8 02 9f 19 4d 62 20 07 17 68 09 ef 89 5c";
            
            CloudStorageAccount acct = CloudStorageAccount.Parse(acctConnectString);

            AzureTableKeyGenerator keyGen = new AzureTableKeyGenerator(certThumbprint);
            keyGen.CreateNewKey(acct, 3);
        }
    }
}
